﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
//using System.Web.DynamicData;
using OA.Model;
using OA.Model.MyAttribute;
using OA.Core;


namespace OA.Model
{

    [Table("TestPaper")]
    public class TestPaper : BaseInfo
    {
        public int Status { get; set; }

        [MaxLength(20)]
        [Display(Name = "主题")]
        [Tag(TagEnum.Text, "required", "主题", 2, 20)]
        [Required]
        public string Title { get; set; }


        [Display(Name = "开始时间")]
        [Tag(TagEnum.DateTime, "required", "开始时间", 2, 20)]
        public DateTime StartTime { get; set; }

        [Display(Name = "结束时间")]
        [Tag(TagEnum.DateTime, "required", "结束时间", 2, 20)]
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 出卷人
        /// </summary>
        [MaxLength(10)]
        public string EmpID { get; set; }

        [MaxLength(1000)]
        [Display(Name = "描述")]
        [Tag(TagEnum.TextArea, "", "描述", 2, 1000)]
        public string Description { get; set; }

        public decimal Score { get; set; }


        public string ExamTopicContent { get; set; }

    }

    public class ApiTestPaperItem: TestPaperItem
    {
        public string TypeName { get { return MyEnum.GetEnumNameByValue(this.Type, typeof(VoteItemType)); } }
        /// <summary>
        /// 我的选择项
        /// </summary>
        public List<string> MySelect { get; set; }

        public string MyAnswer { get; set; }

        public List<TestPaperOptionItem> OptionItem { get; set; }
    }

    public class TestPaperOptionItem
    {
        /// <summary>
        /// A B  
        /// </summary>
        public string Key { get; set; }

        public string Option { get; set; }

        public bool IsSelect { get; set; }

        public int Index { get; set; }
    }

    public class TestPaperItem
    {
        public int ID { get; set; }

        public int Status { get; set; }

        [MaxLength(20)]
        [Display(Name = "主题")]
        [Tag(TagEnum.Text, "required", "主题", 2, 20)]
        [Required]
        public string Title { get; set; }


        /// <summary>
        /// 1:单选 2:多选 3:问答
        /// </summary>
        [Tag(TagEnum.Select, typeof(VoteItemType), "", true)]
        public int Type { get; set; } 

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; set; }

        public string ItemContent { get; set; }

        /// <summary>
        /// 正确答案 1
        /// </summary>
        public string Answer { get; set; }


        public decimal Score { get; set; }

        /// <summary>
        /// 解析
        /// </summary>
        [MaxLength(200)]
        public string Description { get; set; }

    }

    public class SimpleTestPaper : SimpleInfo
    {
        public string Title { get; set; }

        public DateTime StartTime { get; set; }

        public DateTime EndTime { get; set; }

        public decimal Score { get; set; }

        public static Expression<Func<TestPaper, SimpleTestPaper>> Map = m => new SimpleTestPaper()
        {
            ID = m.ID,
            Title = m.Title,
            StartTime = m.StartTime,
            EndTime = m.EndTime,
            Score=m.Score
        };
    }


}
